<?php
namespace App\Http\Controllers\Admin;

use App\Models\Company;
use App\Models\CompanyScale;
use App\Models\CompanyDevelop;
use App\Models\CompanyAuth;
use App\Models\Tags;
/**
 *
 * @author Joker
 *        
 */
class TeachesEnterpriseController extends BaseController
{
    /**
     *  企业首页
     */
    public function index()
    {
        if(!$this->user->can('viewTeachesCompany')) abort(405);
        
        $company = Company::where('is_teaches','=',1)->orderBy('teaches_at','desc')->orderBy('teaches_at','desc')->orderBy('id','desc')->paginate(20);
        return view('admin.teaches.company')->with('company',$company);
    }
    
    /**
     * 企业详情页面
     */
    public function show($id)
    {
        if(!$this->user->can('viewTeachesCompany')) abort(405);
        
        $company = Company::where('id','=',$id)->first();
        $scales = CompanyScale::all();
        $develops = CompanyDevelop::all();
        $authes = CompanyAuth::all();
        $result = $company->tags;
        $tags = array();
        foreach ($result as $res)
        {
            $tags[] = Tags::where('tags_id','=',$res->tags_id)->first()->tags_name;
        }
    
        return view('admin.enterprise.company.details')
            ->with('result',$company)
            ->with('develops',$develops)
            ->with('tags',$tags)
            ->with('authes',$authes)
            ->with('blademode','edit')
            ->with('scales',$scales);
    }
    
}